﻿using System;
using System.Data;
using Model.Data;
using Model;
using DataAccess;
using BusinessLogic.BusinessRules;
using System.Data.OleDb;

namespace BusinessLogic.ClassFactory
{
    /// <summary>
    /// UserManageInfoFactory 的摘要说明。
    /// </summary>
    public class UserManageInfoFactory : BaseFactory
    {
        public UserManageInfoFactory()
            : base()
        {
            //
            // TODO: 在此处添加构造函数逻辑
            //
        }
        public UserManageInfoFactory(DBManager l_DBManager)
            : base(l_DBManager)
        {
        }
        public UserManageInfo NewInstance()
        {
            UserManageInfoAccess l_Access = new UserManageInfoAccess(m_Manager);
            UserManageInfo objUserManageInfo = new UserManageInfo(this.m_Manager, l_Access);
            objUserManageInfo.NewDataSet();
            objUserManageInfo.SelectRow(0);
            return objUserManageInfo;
        }

        public UserManageInfo CreatorBySql(string Sql)
        {
            UserManageInfoAccess l_Access = new UserManageInfoAccess(m_Manager);
            UserManageInfo objUserManageInfo = new UserManageInfo(this.m_Manager, l_Access);
            DataSet l_ds = new UserManageInfoData();
            if (l_Access.QueryBySql(ref l_ds, Sql) < 1)
            {
                return null;
            }
            objUserManageInfo.SetDataSet(l_ds);
            objUserManageInfo.SelectRow(0);
            return objUserManageInfo;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="intUserID"></param>
        /// <returns></returns>
        public UserManageInfo Creator(int intUserID)
        {
            UserManageInfoAccess l_Access = new UserManageInfoAccess(m_Manager);
            UserManageInfo objUserManageInfo = new UserManageInfo(this.m_Manager, l_Access);
            DataSet l_ds = new UserManageInfoData();
            if (l_Access.QueryByID(ref l_ds, intUserID) < 1)
            {
                return null;
            }
            objUserManageInfo.SetDataSet(l_ds);
            objUserManageInfo.SelectRow(0);
            return objUserManageInfo;
        }

        public UserManageInfo Creator()
        {
            UserManageInfoAccess l_Access = new UserManageInfoAccess(m_Manager);
            UserManageInfo objUserManageInfo = new UserManageInfo(this.m_Manager, l_Access);
            DataSet l_ds = new UserManageInfoData();
            if (l_Access.QueryAll(ref l_ds) < 1)
            {
                return null;

            }
            objUserManageInfo.SetDataSet(l_ds);
            objUserManageInfo.SelectRow(0);
            return objUserManageInfo;
        }

        public UserManageInfo CreatorByParm(string Sql, string strValue)
        {
            OleDbParameter parameters = new OleDbParameter("@chvLoginName", OleDbType.VarWChar, 30);
            parameters.Value = strValue;
            UserManageInfoAccess l_Access = new UserManageInfoAccess(m_Manager);
            UserManageInfo objUserManageInfo = new UserManageInfo(this.m_Manager, l_Access);
            DataSet l_ds = new UserManageInfoData();
            if (l_Access.QueryByWhereParam(ref l_ds, Sql, parameters) < 1)
            {
                return null;
            }
            objUserManageInfo.SetDataSet(l_ds);
            objUserManageInfo.SelectRow(0);
            return objUserManageInfo;
        }
    }
}
